package com.orange.score.model.config;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
import com.orange.common.util.DateUtil;
import com.orange.score.constants.LanguageType;
import java.util.Date;

public class ConfigManager
{
  private static final String IS_FIRST_USAGE = "IS_FIRST_USAGE";
  private static final String TAG = "ConfigManager";
  private static ConfigManager configManager = new ConfigManager();
  private static LanguageType languageType = LanguageType.MANDARY;
  private static SharedPreferences sharePreference;
  long serverDiffTime = 0L;

  public static ConfigManager getInstance()
  {
    return configManager;
  }

  public static LanguageType getLanguage()
  {
    LanguageType localLanguageType;
    if (sharePreference == null)
      localLanguageType = LanguageType.MANDARY;
    while (true)
    {
      return localLanguageType;
      int i = sharePreference.getInt("LanguageType", LanguageType.MANDARY.intValue());
      languageType.setIntValue(i);
      Log.i("ConfigManager", "languageType value is " + i);
      localLanguageType = languageType;
    }
  }

  public static long getServerDifferenceTime()
  {
    return getInstance().serverDiffTime;
  }

  public static void setLanguage(int paramInt)
  {
    if (paramInt == 0)
      languageType = LanguageType.MANDARY;
    while (true)
    {
      while (true)
      {
        Log.i("ConfigManager", "set languageType value=" + paramInt);
        sharePreference.edit().putInt("LanguageType", paramInt).commit();
        return;
        if (paramInt != 1)
          break;
        languageType = LanguageType.CANTONESE;
      }
      languageType = LanguageType.CROWN;
    }
  }

  public static void setLanguage(LanguageType paramLanguageType)
  {
    languageType = paramLanguageType;
    int i = paramLanguageType.intValue();
    Log.i("ConfigManager", "set languageType value=" + i);
    sharePreference.edit().putInt("LanguageType", i).commit();
  }

  public boolean getIsFirstUsage()
  {
    return sharePreference.getBoolean("IS_FIRST_USAGE", true);
  }

  public String getRefreshInterval()
  {
    return sharePreference.getString("refleshTime_editTextPref", "20");
  }

  public boolean isNotAutoLock()
  {
    boolean bool = sharePreference.getBoolean("autoLock_checkboxPref", true);
    Log.i("ConfigManager", "not autolock is" + bool);
    return bool;
  }

  public boolean isScorePush()
  {
    return sharePreference.getBoolean("push_checkboxPref", true);
  }

  public boolean isSound()
  {
    return sharePreference.getBoolean("sound_checkboxPref", true);
  }

  public boolean isVibrate()
  {
    return sharePreference.getBoolean("vibrate_checkboxPref", true);
  }

  public void setIsFirstUsage()
  {
    SharedPreferences.Editor localEditor = sharePreference.edit();
    localEditor.putBoolean("IS_FIRST_USAGE", false);
    localEditor.commit();
  }

  public void setServerDifferenceTime(String paramString)
  {
    Date localDate1 = DateUtil.dateFromChineseStringByFormat(paramString, DateUtil.DATE_FORMAT);
    Date localDate2 = new Date();
    this.serverDiffTime = ((localDate1.getTime() - localDate2.getTime()) / 1000L);
    Log.d("ConfigManager", "update server difference time to " + this.serverDiffTime + " seconds");
  }

  public void setSharePreference(SharedPreferences paramSharedPreferences)
  {
    sharePreference = paramSharedPreferences;
  }
}